<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>推荐位配置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/template.css" media="all">
    <style>
        .set-inline{
            width: 250px !important;
        }
        .layui-form-item .layui-inline {
            margin-bottom: 0px;
            margin-right: 0px;
        }
        .layui-card span[lay-separator] {
            margin: 0 10px;
            color: #999;
            font-weight: bold;
        }
    </style>
</head>
<body>


<div class="layui-fluid layadmin-homepage-fluid">

    <div class="layadmin-homepage-panel">
        <div class="layui-card">
            <div class="layui-card-header">
                读者默认书架
                <i class="layui-icon layui-icon-tips" lay-tips="随机从书单抽取9本展示在读者阅读记录下方，每次进入阅读记录页刷新" lay-offset="-10"></i>
            </div>
            <div class="layui-card-body">
            <form class="layui-form layui-form-pane" action="">

                <div class="layui-form-item">
                    <label class="layui-form-label">代理商</label>
                    <div class="layui-input-block" style="">
                        <select name="agent_id" lay-search lay-filter="search">
                            <option value="">请选择</option>
                            <option value="0" {$agent_id === '0' ? 'selected' : ''}>分销平台</option>
                            {foreach $agents as $v}
                            <option value="{$v.id}" {if $agent_id == $v.id}selected{/if}>{$v.account}【{$v.remarks}】</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label" style="cursor: pointer;" lay-tips="不同读者不同的推荐位">读者分类</label>
                    <div class="layui-input-block">
                        <input type="radio" name="type" lay-filter="type" value="1" title="广告线上" {if $type == 1}checked{/if}>
                        <input type="radio" name="type" lay-filter="type" value="2" title="屏蔽地区" {if $type == 2}checked{/if}>
                    </div>
                </div>
            </form>
            </div>
        </div>
    </div>


    <div class="layui-row layui-col-space8">

        <div class="layui-col-md12">
            <div class="layadmin-homepage-panel">
                <div class="layui-row layui-col-space20 layadmin-homepage-list-imgtxt">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                                <div class="layui-card-body">
                                    <table id="LAY-novel-heat" lay-filter="LAY-novel-heat"></table>
                                    <script type="text/html" id="classTpl">
                                        {{#  if(d.freq){ }}
                                        {{d.freq.name}}
                                        {{#  } }}
                                        {{#  if(d.novel_class){ }}
                                        <span lay-separator="">·</span>{{d.novel_class.name}}
                                        {{#  } }}
                                    </script>
                                    <script type="text/html" id="toolbarHeat">
                                        <div class="layui-btn-container">
                                            <button class="layui-btn layui-btn-primary layui-border-red layui-btn-sm" lay-event="del">批量删除</button>
                                            <button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
                                        </div>
                                    </script>
                                </div>
                            </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="table-useradmin-admin">
    <a class="layui-btn layui-btn-primary layui-border-red layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete" ></i>移除</a>
</script>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index'],function () {
        var $ = layui.$
            ,admin = layui.admin
            ,form = layui.form;

        //监听选择App
        form.on('select(search)', function(data){
            console.log(data.value); //得到被选中的值
            location.href = "/website/defaultBookshelf?agent_id=" + data.value + "&type={$type}";
        });

        form.on('radio(type)', function(data){
            console.log(data.value); //得到被选中的值
            location.href = "/website/defaultBookshelf?agent_id={$agent_id}&type=" + data.value;
        });

        form.on('submit(formDemo)', function(data){
            admin.req({
                url: '/website/setTaskConfig'
                , type: "POST"
                , data: data.field
                , done: function (res) {
                    layer.msg('设置成功', {icon: 1, time: 1000}, function () {
                    });
                }, not_finish: function (res) {
                    layer.msg(res.msg,function () {
                        window.location.reload();
                    });
                }
            });
            return false;
        });
    });
</script>
{include file="website/bookshelf_novels" /}
</body>
</html>